# leetcode 225 用队列模拟栈



class MyStack:

    def __init__(self):
        self.data = []
        self.size = 0


    def push(self, x: int) -> None:
        self.data.append(x)
        self.size += 1


    def pop(self) -> int:
        if self.size < 1:
            return 
        else:
            n = self.size
            for i in range(n - 1):
                tmp = self.data.pop()
                self.push(tmp)
            self.size -= 1
            return self.data.pop()


    def top(self) -> int:
        if self.size < 1:
            return 
        else:
            n = self.size
            for i in range(n - 1):
                tmp = self.data.pop()
                self.push(tmp)
            ret = self.data.pop()
            self.push(ret)
            return ret


    def empty(self) -> bool:
        if not self.data:
            return True
        return False
